<?php
namespace App\Models\WechatMsg;

use App\Models\UserClock;
use App\Models\UserProject;
use App\Models\UserTeam;

class RecReward
{
    public  $type;
    public $content;

    public function __construct($type, $content)
    {
        $this->content = $content;
        $this->type = $type;
    }

    public function getOrgWechatConfig()
    {
        $userClock = UserClock::where('id', $this->content['user_clock_id'])->first();

        $conf['templateId'] = $userClock->user->org->wechat_message_config['sign_on_vol'];

        $options = config('wechat');

        $options['app_id'] = $userClock->user->org->wechat_app_id;
        $options['secret'] = $userClock->user->org->wechat_app_secret;

        $conf['options'] = $options;

        $conf['openId'] = $userClock->user->open_id;

        $conf['url'] = $userClock->user->org->getBaseUrl();

        return $conf;
    }


    public function getMessageData()
    {
        $userClock = UserClock::where('id', $this->content['user_clock_id'])->first();

        $data['first'] = "{$userClock->project->name}签到通知";

        $data['keyword1'] = "{$userClock->user->username}已签到";
        $data['keyword2'] = date('Y年m月d日 H:i' );
        $data['remark'] = '感谢您的使用';

        return $data;
    }
}